require 'Sockets/HTTPSocket'
require 'rexml/document'

class TwitClient
  TWITTER_HOST = 'www.twitter.com'
  TWITTER_PORT = 80
  
  def initialize(sAuthString)
	@hsTwitSock = HTTPSocket::new(TWITTER_HOST,TWITTER_PORT)
	@hsTwitSock.AddHeader('Authorization','Basic '+sAuthString)
	@hsTwitSock.AddHeader("User-Agent", "TwitClient/Ruby");
  end

  def GetFriendsTimeline(iCount)
	aData = Array.new
	sBody = @hsTwitSock.GetURL('/statuses/friends_timeline.xml')
	xdData = REXML::Document.new(sBody)
	
	xdData.elements.each('statuses/status'){ |xnNode|
		aData << {'name' => xnNode.elements['user/name'].text,'tweet' => xnNode.elements['text'].text}
    }
	return aData
  end
end